﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace EvoWars2.Stuffs
{
    public class CollisionDetection2D
    {


        public bool IsCollidingWithAny(Rectangle dynamicObject, List<Rectangle> obstacleList)
        {
            bool isColliding = false;
            foreach (Rectangle obstacle in obstacleList)
            {
                if (dynamicObject.Intersects(obstacle))
                {
                    isColliding = true;
                    break;
                }
            }


            return isColliding;
        }

        public List<Rectangle> GetCollidingWith(Rectangle dynamicObject, List<Rectangle> obstacleList)
        {

            List<Rectangle> collidingList = new List<Rectangle>();

            foreach (Rectangle obstacle in obstacleList)
            {
                if (dynamicObject.Intersects(obstacle))
                {
                    collidingList.Add(obstacle);

                }
            }
            return collidingList;
        }


    }
}
